package com.ie.controller.admin;

import com.ie.common.http.ResponseResult;
import com.ie.common.security.anno.AuthIgrone;
import com.ie.entity.GoodsTypeEntity;
import com.ie.service.admin.GoodsTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @Description: //TODO
 * @Author: S2
 * @Date: 2025/5/8  9:01
 * @Param:
 * @version: 1.0
 * @Return:
 **/
@RestController
@RequestMapping("/api/admin/type")
public class GoodsTypeContoller {
    @Autowired
    private GoodsTypeService goodsTypeService;

    // private final GoodsTypeService goodsTypeService;
    //
    // public GoodsTypeContoller(GoodsTypeService goodsTypeService) {
    //     this.goodsTypeService = goodsTypeService;
    // }
    @AuthIgrone// TODO:忽略权限
    @PostMapping("/getAllGoodsType")
    public ResponseResult<List<GoodsTypeEntity>> getAllGoodsType() {
        return ResponseResult.getSuccessResult(goodsTypeService.list());
    }
    @AuthIgrone// TODO:忽略权限
    @PostMapping("/getGoodsType")
    public ResponseResult<Map<String,Object>> getGoodsType(@RequestBody GoodsTypeEntity goodsTypeEntity) {
        return goodsTypeService.getGoodsType(goodsTypeEntity);
    }
    @AuthIgrone// TODO:忽略权限
    @PostMapping("/add")
    public ResponseResult<Map<String,Object>> addGoodsType(@RequestBody GoodsTypeEntity goodsTypeEntity) {
        return goodsTypeService.addGoodsType(goodsTypeEntity);
    }
    @AuthIgrone// TODO:忽略权限
    @PostMapping("/delete")
    public ResponseResult<Map<String,Object>> deleteGoodsType(@RequestBody GoodsTypeEntity goodsTypeEntity) {
        return goodsTypeService.deleteGoodsType(goodsTypeEntity);
    }
    @AuthIgrone// TODO:忽略权限
    @PostMapping("/update")
    public ResponseResult<Map<String,Object>> updateGoodsType(@RequestBody GoodsTypeEntity goodsTypeEntity) {
        return goodsTypeService.updateGoodsType(goodsTypeEntity);
    }
}
